import Vue from 'vue'
import App from './App.vue'
import store from './store'
import router from './router'
import './plugins/element.js'
import './assets/fonts/iconfont.css'
// 导入全局样式表
import './assets/css/global.css'

import VueQuillEditor from 'vue-quill-editor' // 导入 VueQuillEditor，不带 {}

// 新增：导入样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

// 新增：注册组件
Vue.use(VueQuillEditor) // 这里用的是 use

import TreeTable from 'vue-table-with-tree-grid'

import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

import axios from 'axios'
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
axios.interceptors.request.use(config=>{
  config.headers.Authorization = window.sessionStorage.getItem('token');
  NProgress.start();
  return config;
})

axios.interceptors.response.use(config=>{
  NProgress.done();
  return config;
})
Vue.prototype.$http = axios

Vue.config.productionTip = false

Vue.component('tree-table',TreeTable)

Vue.filter('dateFormat',function(originVal){
  // console.log(originVal);
  const date = new Date(originVal);
  const year = date.getFullYear();
  const month = (date.getMonth()+1+'').padStart(2,'0');
  const day = (date.getDate()+'').padStart(2,'0');

  const hour = (date.getHours() + '').padStart(2,'0');
  const minute = (date.getMinutes() + '').padStart(2,'0');
  const second = (date.getSeconds() + '').padStart(2,'0');
  // return year + month + day + ' ' + hour + minute + second;
  return `${year}-${month}-${day} ${hour}:${minute}:${second}`
})

new Vue({
  store,
  router,
  render: h => h(App)
}).$mount('#app')
